00:00
02:42

Hands-on Lab: Getting Started with Jupyter Notebooks

Duration: 10 mins

Objective

In this lab, you will perform basic tasks in the Jupyter notebook -

  • Add descriptive text and code
  • Execute and render the notebook

Pre-requisites

  • IBM Cloud account

Before proceeding with this lab, please ensure you have created a IBM Cloud trial account using the feature code provided to you within the course. If not please ensure you complete the previous lab: IBM Cloud Account Setup.

  • Setting up Watson Studio service and adding Jupyter notebook

After creating IBM Cloud account,you must create a Watson Studio service on IBM Cloud and add a Jupyter notebook to it. If not please ensure you complete the previous lab: Creating a Watson Studio Project with Jupyter Notebooks.

Task : Add descriptive text and code to your Jupyter notebook

In this lab you will get started with Jypter notebook and learn how to add code and descriptive text to the cell. You will then execute and render the Jupyter notebook to see the final output.

There are two main cell types that we will cover:

A code cell contains code to be executed in the kernel. When the code is run, the notebook displays the output below the code cell that generated it.

A Markdown cell contains text formatted using Markdown and displays text as output when the Markdown cell is executed.

Now that you have an open Jupyter notebook in front of you, notice that there is a blank cell is already added to your notebook and there is a Kernel selection on top right corner that displays either Pythion or R version which you selected at the time of creating Jupyter notebook.

  1. Enter the text in the cell as This program prints Hello, World!.

  2. Change the cell type to Markdown.

  3. Click the Run icon or press Ctrl + Enter on your keyboard. to run your code. This will render the text as output.

  4. The result should look like this -

  5. To insert a new cell below this, click on the icon to the far right in the cell as shown below -

  6. Enter the text in the cell as print('Hello, World!'). Change the cell type to Code.

  7. Again, click the Run icon or press Ctrl + Enter on your keyboard. to run your code.

  8. Your final Jupyter notebook appears as shown below -

This concludes this tutorial.

For more details on creating Jupyter Notebook editor on IBM Watson Studio, please refer to this link - Quick start: Analyze data in a Jupyter notebook.

Author(s)

Shilpa Giridhar

cognitiveclass.ai logo